<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="content">
                <!-- NEW SPOT ################################################################# -->  
                <h:form id="restForm">                           
                    <p:panel header="Pick a Restaurant" id="selectedRest">

                        <h:messages errorClass="error"/> 

                        <h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">  
                            <h:outputLabel value="Search: "/>
                            <p:inputText id="keyword" value="#{newBean.keyword}" label="Keyword" >
                                <p:ajax event="change" update="restList" listener="#{newBean.findRestaurants()}" />
                            </p:inputText>
                            <p:watermark for="keyword" value="Search with a keyword" />
                        </h:panelGrid>
                            
                        <p:selectOneListbox id="restList" value="#{newBean.restId}">
                            <f:selectItem itemLabel="Select Restaurant" />
                            <f:selectItems value="#{newBean.restList}" var="restaurant" itemLabel="#{restaurant.name}" itemValue="#{restaurant.rid}" />
                        </p:selectOneListbox>
                        <p:commandButton value="Set" update="panel" /> 
                        <p:commandButton id="showNewRDialogButton" type="button" value="Add New Restaurant" onclick="newRestDlg.show()" />
                    </p:panel>
                    <p:panel id="panel">
                        <h:outputText value="#{newBean.restId}" />
                    </p:panel>
                </h:form>
                <h:form>
                    <p:panel header="Add New Spot" id="newSpot">

                        <h:messages errorClass="error"/>

                        <h:panelGrid columns="2" columnClasses="label, value">
                            <h:outputText value="Name: " />
                            <p:inputText value="#{wizardBean.spot.name}" />

                            <h:outputText value="Image: " />
                            <p:inputText value="#{wizardBean.spot.pic}" />

                            <h:outputText value="Note: " />
                            <p:inputText value="#{wizardBean.spot.note}" />
                        </h:panelGrid>

                        <p:commandButton value="Add" update=":growl" actionListener="#{wizardBean.save()}"/>
                    </p:panel>            
                </h:form> 
            </ui:define>

        </ui:composition>

    </body>
</html>
